﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core
{
    public class DataType : IEquatable<DataType>
    {
        internal DataType(Guid pID, string pSQLDataTypeName,
            bool pMustSpecifyLength, bool pIndexable)
        {
            ID = pID;
            SQLDataTypeName = pSQLDataTypeName;
            MustSpecifyLength = pMustSpecifyLength;
            Indexable = pIndexable;
        }

        public Guid ID
        {
            get;
            private set;
        }

        public string SQLDataTypeName
        {
            get;
            private set;
        }

        public bool MustSpecifyLength
        {
            get;
            private set;
        }

        public bool Indexable
        {
            get;
            private set;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (DataType)) return false;
            return Equals((DataType) obj);
        }

        public bool Equals(DataType other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.ID.Equals(ID);
        }

        public override int GetHashCode()
        {
            return ID.GetHashCode();
        }
    }
}
